const crypto = require('crypto');

var t = "/search"
var n = "/house"
var i = "GET"
var u = {
    "sequence": "",
    "city": "上海",
    "region": "",
    "distance": "",
    "longitude": "",
    "latitude": "",
    "stations": "",
    "bed_count": "",
    "rent_type": "",
    "sort": "",
    "cost1": "",
    "cost2": ""
}

var r = exports.timeStamp = function () {
    return Math.round((new Date).getTime() / 1e3)
}

// MD5加密函数
var o123 = function (data) {
    // 使用Node.js标准库crypto进行MD5加密
    return crypto.createHash('md5').update(String(data)).digest('hex');
}

function getAuthorization2(e, t) {
    var n = r()
    // var n = 1763212760
        , s = o123(n)
        , a = o123(n)
        , c = t ? t.toLowerCase() : "get"
        , i = "client/search/house"
        ,
        u = "request_url=".concat(i, "&content=").concat(n, "&request_method=").concat(c, "&timestamp=").concat(n, "&secret=").concat(s)
        , l = o123(u);
    return "timestamp=".concat(n, ";oauth2=").concat(a, ";signature=").concat(l, ";secret=").concat(s)
}

function getAuthorization(){
    return getAuthorization2(t + n, i, u)
}
console.log(getAuthorization())


// timestamp=1763212760;oauth2=f29f144cf62dc529192efc0746037eb7;signature=f43153c60dae615f920db9be594cec98;secret=f29f144cf62dc529192efc0746037eb7
